<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/index/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/index/css/swiper.min.css"/>
    <script type="text/javascript" src="__STATIC__/index/js/rem.js"></script>
    <title>一官安</title>
</head>
<body class="geryBg">
<div class="order_manage">
    <!--二级导航-->
    <div class="sub_nav whiteBg">
        <div class="swiper-container" id="swiper">
            <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <a href="/index/order/index"><span {if empty($Think.get.type)} class="on" {/if}>全部</span></a>
                </div>
                <div class="swiper-slide">
                    <a href="javascript:location.replace('?type=1')"><span {if $Think.get.type=='1'} class="on" {/if}>待付款</span></a>
                </div>
                <div class="swiper-slide">
                    <a href="javascript:location.replace('?type=2')"><span {if $Think.get.type=='2'} class="on" {/if}>待发货</span></a>
                </div>
                <div class="swiper-slide">
                    <a href="javascript:location.replace('?type=3')"><span {if $Think.get.type=='3'} class="on" {/if}>待收货</span></a>
                </div>
                <div class="swiper-slide">
                    <a href="javascript:location.replace('?type=4')"><span {if $Think.get.type=='4'} class="on" {/if}>已完成</span></a>
                </div>
                <div class="swiper-slide">
                    <a href="javascript:location.replace('?type=5')"><span {if $Think.get.type=='5'} class="on" {/if}>已售后</span></a>
                </div>
            </div>
        </div>
    </div>

    <!--全部-->
    <div class="order_content block" data-status="0">
        <ul class="content_list">
            <!--待付款-->
            {foreach $order as $vo}
            <li>
                <a href="detail?id={$vo.id}">
                <!--订单编号-->
                <div class="clear normall-text whiteBg order_status bold">
                    <p class="fl smoth">订单号：{$vo.order_num}</p>
                    <p class="fr brown status">
                        {if $vo.status==1}待付款
                        {elseif $vo.status==2}{if $vo.shouhou_status==0}待发货{elseif $vo.shouhou_status==1}申请退款中{/if}
                        {elseif $vo.status==3}待收货
                        {elseif $vo.status==4}已签收
                        {elseif $vo.status==5}{if $vo.shouhou_status==3}已退款
                                                {elseif $vo.shouhou_status==4}审核中
                                                {elseif $vo.shouhou_status==5}待寄回
                                                {elseif $vo.shouhou_status==6}待商家收货
                                                {elseif $vo.shouhou_status==7}未通过
                                                {elseif $vo.shouhou_status==8}已退款
                                                {elseif $vo.shouhou_status==10}已撤销
                                                {/if}
                        {/if}
                    </p>
                </div>
                <!--订单内容-->
                {foreach $vo.orderlist as $v}
                <div class="content_msg clear">
                    <!--商品图片 尺寸:190*190-->
                    <div class="content_img fl">
                        <img class="auto-img" src="{$v.goods_spec_img}"/>
                    </div>
                    <!--商品描述-->
                    <div class="content_des fr">
                        <p class="super-text smoth bold">{$v.goods_title}</p>
                        <p class="normall-text lightgery">{$v.goods_spec}</p>
                        <div class="clear good_price">
                            <p class="fl super-text bold brown">￥{$v.price}</p>
                            <p class="fr super-text bold smoth"><em class="small-text">X</em>{$v.num}</p>
                        </div>
                    </div>
                </div>
                {/foreach}
                </a>
                <!--订单状态-->
                <div class="whiteBg clear order_btn">
                    <div class="clear">
                        <div class="good_account">
                            <p class="normall-text smoth"> 实付: <em class="brown">￥{$vo.pay}</em></p>
                        </div>
                        <!--操作按钮-->
                        <div class="option_btn fr">
                            {if $vo.status==1}
                            <button class="gery" data-value="{$vo.id}">取消订单</button>
                            <button class="brown" data-value="{$vo.id}">立即付款</button>
                            {elseif $vo.status==2}

                            <button class="brown">联系客服</button>
                            {elseif $vo.status==3}
                            <button class="gery" data-value="{$vo.id}">查看物流</button>
                            <button class="brown" data-value="{$vo.id}">确认收货</button>
                            {elseif $vo.status==4}
                            {php}$jiesuan_time = strtotime($vo['jiesuan_time']);if($jiesuan_time>time()){{/php}
                            <button class="gery" data-value="{$vo.id}">申请售后</button>
                            {php}}{/php}
                            <button class="brown" data-value="{$vo.id}">立即评价</button>
                            {/if}
                        </div>
                    </div>
                </div>
            </li>
            {/foreach}
        </ul>
    </div>

    <p class="text-center normall-text nomore lightgery">暂无更多</p>
</div>
<!--弹窗联系客服-->
<div class="cart_pop">
    <div class="pop_msg">
        <img class="pop_close" src="__STATIC__/index/img/icon-close.png" onclick="hideTips('.cart_pop')"/>
        <p class="text-center super-text smoth bold"></p>
        <div class="pop_btn">
            <button class="cancel" onclick="hideTips('.cart_pop')">取消</button>
            <button id="ensure" class="ensure">确定</button>
            <a id="kefu" style="width: 1.7rem;height: 0.6rem;border-radius: 0.1rem;font-size: 0.26rem;line-height: 0.6rem;text-align: center;display: block;" href="tel:{:conf('kefu')}" class="ensure">确定</a>
        </div>
    </div>
</div>
<script type="text/javascript" src="__STATIC__/index/js/swiper.min.js"></script>
<script type="text/javascript" src="__STATIC__/index/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="__STATIC__/index/js/config.js"></script>
<script type="text/javascript">
    //标题滑动
    window.onload = function () {
        var swiper = new Swiper('#swiper', {
            slidesPerView: 'auto',
            observer: true,
            observeParents: true
        })
    }

    //弹出框
    function showTips(classname) {
        return $(classname).show()
    }

    function hideTips(classname) {
        return $(classname).hide()
    }

    //切换标题
    $('.sub_nav .swiper-slide span').on('click', function () {
        $(this).addClass('on').parents('.swiper-slide').siblings().find('span').removeClass('on')
        var index = $(this).parents('.swiper-slide').index()
        $('.order_content').eq(index).addClass('block').siblings().removeClass('block')
    })
    //弹窗禁止手指滑动
    $('.cart_pop').on('touchmove', function (e) {
        e.preventDefault()
    })
    //点击按钮操作
    $('.option_btn button').on('click', function () {
        if ($(this).text() == '立即付款') {
            //点击立即付款按钮
            window.location.href = 'detail?id='+$(this).data('value');
        } else if ($(this).text() == '取消订单'){
            //点击取消订单
            window.location.href = 'detail?id='+$(this).data('value');
        } else if ($(this).text() == '联系客服') {
            //点击联系客服按钮
            showTips('.cart_pop');
            hideTips('#ensure');
            showTips('#kefu');
            $('.cart_pop .pop_msg p').html('确认拨打{:conf("kefu")}吗?');
            $('.ensure').on('click', function () {
                hideTips('.cart_pop');
            })
        } else if ($(this).text() == '查看物流') {
            //点击查看物流按钮
            window.location.href = 'detail?id='+$(this).data('value');
        } else if ($(this).text() == '确认收货') {
            //点击确认收货
            window.location.href = 'detail?id='+$(this).data('value');
        } else if ($(this).text() == '撤销申请') {
            //撤销申请操作
            showTips('.cart_pop')
            //弹出弹窗
            $('.cart_pop .pop_msg p').html('是否撤销申请?')
            //弹出框内容改变
            var self = $(this)
            //改变this指向
            $('.ensure').on('click', function () {
                //点击确定事件
                hideTips('.cart_pop')
                self.next('button').html('立即评价')
                self.html('申请售后')
                self.parents('li').find('.status').html('已完成')
                if (!self.parents('.option_btn').children('button').hasClass('brown')) {
                    //如果是审核中状态
                    self.parents('.option_btn').append('<button class="brown"><a href="./order_comment.html">立即评价</a></button>')
                    //插入一个button
                }
            })
        } else if ($(this).text() == '立即评价') {
            //点击立即评价
            window.location.href = 'detail?id='+$(this).data('value');
        } else if ($(this).text() == '申请售后') {
            //点击申请售后
            window.location.href = 'detail?id='+$(this).data('value');
        } else if ($(this).text() == '寄回去') {
            //点击寄回去
            window.location.href = 'logistic_write.html'
        }
    })
    //点击查看订单详情
    $('.content_msg').on('click', function () {
        if ($(this).prev('.order_status').children('.status').text() == '待付款') {
            //待付款点击
            window.location.href = 'obligation.html'
        } else if ($(this).prev('.order_status').children('.status').text() == '待发货') {
            //待发货点击
            window.location.href = 'wait_sent.html'
        } else if ($(this).prev('.order_status').children('.status').text() == '待收货') {
            //待收货点击
            window.location.href = 'wait_get.html'
        } else if ($(this).prev('.order_status').children('.status').text() == '已完成') {
            //已完成点击
            window.location.href = 'order_completed.html'
        } else if ($(this).prev('.order_status').children('.status').text() == '审核中') {
            //审核中点击
            window.location.href = 'wait_check.html'
        } else if ($(this).prev('.order_status').children('.status').text() == '待寄回') {
            //待寄回点击
            window.location.href = 'wait_resend.html'
        } else if ($(this).prev('.order_status').children('.status').text() == '待商家收货') {
            //待商家收货点击
            window.location.href = 'wait_bussiness.html'
        } else if ($(this).prev('.order_status').children('.status').text() == '未通过') {
            //未通过点击
            window.location.href = 'fail_post.html'
        } else if ($(this).prev('.order_status').children('.status').text() == '已退货') {
            //已退货点击
            window.location.href = 'success_post.html'
        }
    })
    //根据不同状态码显示不同页面
    // var nav_status = parseInt(GetQueryString('status'))
    // $('.sub_nav .swiper-slide span').eq(nav_status).click()
</script>
</body>
</html>